package gold.contest;

import gold.utils.InputUtil;

import java.util.*;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC6120 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int[] numberOfPairs(int[] nums) {
            Set<Integer> cntSet = new HashSet<>();
            int repeatCnt = 0, leftCnt = 0;
            for (int num : nums) {
                if (cntSet.contains(num)) {
                    repeatCnt++;
                    cntSet.remove(num);
                } else {
                    cntSet.add(num);
                }
            }

            leftCnt = nums.length - 2 * repeatCnt;
            return new int[]{repeatCnt, leftCnt};
        }
    }

    public void run() {
        System.out.println(Arrays.toString(new Solution().numberOfPairs(InputUtil.toIntegerArray("[1,3,2,1,3,2,2]"))));
        System.out.println(Arrays.toString(new Solution().numberOfPairs(InputUtil.toIntegerArray("[1,1]"))));
        System.out.println(Arrays.toString(new Solution().numberOfPairs(InputUtil.toIntegerArray("[0]"))));
    }

    public static void main(String[] args) throws Exception {
        LC6120 an = new LC6120();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
